
<?php if (count($languages) > 1) { ?>
<form action="<?php echo $action; ?>"  class="form-language" method="post" enctype="multipart/form-data">
	<select class="drop language">
	    <option class="label"><?php echo $text_language; ?></option>
	    <?php foreach ($languages as $language) { ?>
	    	  <?php if ($language['code'] == $language_code) { ?>
	  			<option value="" selected src="image/flags/<?php echo $language['image']; ?>"><?php //echo $language['name']; ?></option>
	  		<?php }else{ ?>
	  			<option value="<?php echo $language['code']; ?>" src="image/flags/<?php echo $language['image']; ?>"><?php //echo $language['name']; ?></option>
	  		<?php }?>
	  	  <?php } ?>
	    <input type="hidden" name="language_code" value="" />
	    <input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
	</select>
</form>
<?php } ?>

<script>
$(function(){
	$(".drop.language").change(function(e){
		e.preventDefault();
		if($(this).val()){
			$("[name='language_code']").val($(this).val());
			$(".form-language").submit();
		}
	});
});
</script>
